package com.ysw.开发工具系列.swagger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author: yu_sw
 * @Description: com.ysw.开发工具系列.swagger.config
 * @date:2022/5/21 2:11
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(false)
                .groupName("默认组")
                .apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.ysw.开发工具系列.swagger.controller"))
                .build();
    }
    @Bean
    public Docket docket1() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(false).groupName("其他组")
                .apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.ysw.开发工具系列.swagger.controller"))
                .paths(PathSelectors.ant("/swagger/**"))
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("yu_sw", "", "");
        ApiInfo apiInfo = new ApiInfo("yu_sw swagger",
                "swagger learn", "v_1.0",
                "",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
        return apiInfo;
    }
}
